﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.util {
    import Engine.Transactions.*;
    import Engine.Managers.*;
    import Transactions.*;
    import Modules.stats.experiments.*;
    import com.adobe.utils.*;

    public class GameTransactionManager {

        private static var m_listeners:Array = [];

        public static function addListener(_arg1:ITransactionManagerListener):void{
            if (!ArrayUtil.arrayContainsValue(m_listeners, _arg1)){
                m_listeners.push(_arg1);
            };
        }
        public static function removeListener(_arg1:ITransactionManagerListener):ITransactionManagerListener{
            if (ArrayUtil.arrayContainsValue(m_listeners, _arg1)){
                ArrayUtil.removeValueFromArray(m_listeners, _arg1);
                return (_arg1);
            };
            return (null);
        }
        public static function addTransaction(_arg1:Transaction, _arg2:Boolean=false, _arg3:Boolean=false):void{
            var _local4:ITransactionManagerListener;
            if (((((_arg2) && (!(_arg3)))) && (Global.experimentManager.inPerfExperiment(ExperimentDefinitions.EXPERIMENT_OPTIMIZE_WAITTIME, ExperimentDefinitions.EXPERIMENT_OPTIMIZE_NONUSERWAIT)))){
                _arg2 = false;
            };
            for each (_local4 in m_listeners) {
                _local4.beforeTransactionAdded(_arg1, _arg2);
            };
            TransactionManager.addTransaction(_arg1, _arg2, _arg3);
            if ((_arg1 is TFarmTransaction)){
                (_arg1 as TFarmTransaction).onAdd();
            };
            for each (_local4 in m_listeners) {
                _local4.afterTransactionAdded(_arg1, _arg2);
            };
        }

    }
}//package Classes.util 
